package com.ruoyi.yf.mapper;

import com.ruoyi.yf.domain.Report;
import com.ruoyi.yf.domain.YfDistrictStatistical;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ReportMapper {


    /**
     * 统计预览 统计年、月、周、日 产量、袋数
     *
     * @return
     * @author XiaoYi...
     * @date 2020/6/4 15:53
     * 63cf32b9-12a5-44ea-9b98-fadb7eaadce3
     */
    public Report previewMain(Long deptId);

    /**
     * 月感控表
     *
     * @return
     * bbf80711-1a36-44cd-b180-01d393c3701a
     */
    @Select("SELECT trashid as name, trashname as type, (SELECT sum( trashweight ) FROM tagmanager WHERE trashtype = a.trashid AND departdate >= #{params.begindate} AND departdate <= #{params.enddate} ) as weight, (SELECT COUNT(*) FROM tagmanager WHERE trashtype = a.trashid AND departdate >= #{params.begindate} AND departdate <= #{params.enddate} ) as number FROM trash a  ORDER BY trashid;")
    public List<Report> reportYGK(Report report);


    /**
     * 月明细报表
     * d1838e29-a1c9-42ed-8abe-f55a37fa0cd3
     */
    @Select("select sum(t.TRASHWEIGHT) as weight ,CONCAT(\"2019-12-\",m.datestr )as createDate  ,d.DEPARTID as Id,d.DEPARTNAME as codeId from tagmanager t left join department d on t.SOURCEOFFICE= d.DEPARTID right JOIN months m on t.departdate like CONCAT(\"2019-12-\",m.datestr,\"%\") GROUP BY m.datestr,d.DEPARTID ORDER BY m.datestr ")
    public List<Report> reportYMX(Report report);

    /**
     * 胎盘统计表
     *
     * @param report
     * @return
     * dbea3cfc-9e34-40c3-b8f7-855df8321385
     */
    @Select("SELECT b.DEPARTNAME as name,'1' as number ,a.TRASHWEIGHT as weight, DEPARTDATE as createDate from tagmanager a LEFT JOIN department b on a.SOURCEOFFICE = b.DEPARTID LEFT JOIN trash c on a.TRASHTYPE = c.TRASHID where c.TRASHNAME like '%胎盘%'  and date_format(DEPARTDATE,'%Y-%m') = #{params.begindate}  ORDER BY DEPARTDATE")
    public List<Report> reportTP(Report report);


    /**
     * 危险废物转移联单 医疗医废专用
     * 241827e6-5f95-4dff-9ee3-e628af7b0704
     */
    @Select("select m.id as id " +
            ",(select count(trashweight) from tagmanager where trashtype = '002' and CARDATE like CONCAT(#{params.begindate},'-',m.datestr,\"%\") )  as count " +
            ",(select sum(trashweight)from tagmanager where trashtype = '002' and CARDATE like CONCAT(#{params.begindate},'-',m.datestr,\"%\") ) as sum " +
            ",(select count(trashweight) from tagmanager where trashtype <> '002' and CARDATE like CONCAT(#{params.begindate},'-',m.datestr,\"%\") ) as number " +
            ",(select sum(trashweight) from tagmanager where trashtype <> '002' and CARDATE like CONCAT(#{params.begindate},'-',m.datestr,\"%\") ) as weight " +
            "from months m")
    public List<Report> reportWXFWZY(Report report);

    /**
     * XiaoYi...
     * 卫生员接收医废
     *
     * @Date : 2020-03-11 10:57
     * c132b448-07a1-406a-bcc2-b528dabad48d
     */
    public List<Report> reportWSYJS(Report report);

    /**
     * 自定义查询sql
     *
     * @param sql
     * @return
     * 6fbe6b03-fc13-4283-b649-c545b1afcf96
     */
    public List<Report> report_select_sql(@Param("sql") String sql);


    /**
     * 查询医废统计列表
     *
     * @param disId
     * @param startDate
     * @param endDate
     * @return
     * 2a8da677-1220-4017-97b4-da26469eebd0
     */
    public List<Report> cityTrashTypeAll(@Param("disId") Long disId, @Param("startDate") String startDate, @Param("endDate") String endDate);

    /**
     * 医废类型统计 详细
     *
     * @param deptId    医院id
     * @param begindate 开始时间
     * @param enddate   结束时间
     * @return
     * 451cd849-16a1-4568-88b9-0cc8dbe3b502
     */
    public List<Report> trashType(@Param("deptId") Long deptId, @Param("begindate") String begindate, @Param("enddate") String enddate);


    /**
     * 条形统计图 存积量 预警值
     *
     * @param disId 医院id
     * @return
     * 0bdc9516-6e98-4396-8651-8c7ea79e148c
     */
    public List<Report> storage_bar(@Param("disId") String disId,@Param("limit") int limit);


    /**
     * @param deptId 医院id
     * @return
     * @author XiaoYi...
     * 累计科室医废 产量、暂存量
     * @date 2020/5/8 14:36
     */
    List<Report> dept_trash_sum_staging(@Param("deptId") Long deptId);

    /**
     * @param deptId 医院id
     * @return
     * @author XiaoYi...
     * 累计医废类型 产量、暂存量
     * @date 2020/5/8 14:36
     * 5b2c17e5-4d8d-4fba-b678-14588832186d
     */
    List<Report> trash_type_sum_staging(@Param("deptId") Long deptId);

    /**
     * @param deptId 医院id
     * @return
     * @author XiaoYi...
     * 当天科室医废 产量、暂存量
     * @date 2020/5/8 14:37
     * e1ef733e-62c2-427b-a1f2-42d08e4f5310
     */
    List<Report> now_day_dept_trash_sum_staging(@Param("deptId") Long deptId);

    /**
     * @param deptId 医院id
     * @return
     * @author XiaoYi...
     * 当天医废类型 产量、暂存量
     * @date 2020/5/8 14:36
     * eaecb81f-fa2f-4ccd-afc1-ecf903af9c73
     */
    List<Report> now_day_trash_type_sum_staging(@Param("deptId") Long deptId);

    /**
     * @param deptId 医院id
     *               累计、日、待入库数量统计
     * @return
     * @author XiaoYi...
     * @date 2020/5/11 11:35
     * 37e88911-1e06-463c-881c-78fd95551424
     */
    Report bagandweight(@Param("deptId") Long deptId);

    /**
     * @param deptId 医院id
     *               收集员周统计产量
     * @return
     * @author XiaoYi...
     * @date 2020/5/12 10:28
     * 0e02e031-260d-4c17-b988-3452617593f9
     */
    List<Report> gathering_week_of_statistics(@Param("deptId") Long deptId);

    Report brashTypeNowSumStatistical(Long deptId);

    /**
     * 积存量变化趋势图
     *
     * @param deptId
     * @return
     * 1ebc9cb9-d58a-4da9-9351-89ef91126aa5
     */
    List<Report> storage_axis(Long deptId);


    /**
     * 获取今年医废总产量、总袋数
     *
     * @param deptId
     * @return
     */
    Report getYearYFTotalWeightAndBags(Long deptId);


    /**
     * 条形统计图 各区域医疗机构数量
     * ae7af095-5633-4273-8376-b66dd18c017e
     */
    List<Report> hospitalNumBarList(@Param("disId") String disId,
                                    @Param("hospitalTypeIds") String hospitalTypeIds,
                                    @Param("limit") int limit);


    /**
     * 医院医废总产量统计排行
     * c457d878-2c6a-409b-8e9d-519dc58ca83a
     */
    List<Report> hospitalYFStatisticsList(Long deptId);


    /**
     * 大屏 -- 医废种类饼状图
     * f416675b-b986-4c02-8ced-f84023232810
     */
    List<Report> trashTypeStatistics(Long deptId);


    /**
     * 区县级卫健局 显示医院数量、暂存点数量
     * 75f3fc8f-5fb0-4fea-a899-a5c0e0a62c22
     */
    Report CountyHospitalNumBarList(String disId);


    /**
     * 区县级卫健局 显示区县级卫健局下属医院、社区 -- 积存量、预警值
     * 68f42923-58b3-4382-8e3a-f5766ec52136
     */
    List<Report> countyStorageBar(@Param("disId") String disId,@Param("limit") int limit);

    /**
     * 获取医院列表 和医院重量 袋数、累计量、当日;
     *
     * @param deptId
     * @return
     * 4ad58998-e2d1-4e75-9088-823fc587db8f
     */
    List<Report> getHospitalWeightBagPoint(@Param("deptId") Long deptId);

    /**
     * 统计报表
     *
     * @param disId
     * @param begindate
     * @param enddate
     * @return
     * 6d28b658-ca33-4533-a4d3-89e8c543a29a
     */
    public List<Report> cityStatistical(@Param("disId") Long disId, @Param("begindate") String begindate, @Param("enddate") String enddate);

    /**
     * 区县级卫健局 -- 显示区县级卫健局下辖医院  -- 产生量、转运量、暂存量
     * abaccc8d-ef0d-4952-bdc3-4fa25976a0bc
     */
    List<Report> countyStatistical(@Param("disId") Long disId, @Param("begindate") String begindate, @Param("enddate") String enddate);


    /**
     * 区县级卫健局 -- 显示区县级卫健局下辖医院  -- 各医废类型
     * e5d7e037-47c4-496e-a969-8914c64168a6
     */
    List<Report> countyTrashTypeAll(@Param("disId") Long disId, @Param("begindate") String begindate, @Param("enddate") String enddate);


    //查询条码最新更新记录
//    be3518ad-6a89-40fe-8cae-d54038a7df34
    List<Report> selectTagUpdateDescLimit(@Param("deptId") Long deptId, @Param("limit") int limit);


    // 定时查询某天的医废统计
    //f6f8b531-423c-4fe8-84c1-8a5a93fb492f
    List<YfDistrictStatistical> getDistrictYFStatistical(@Param("districtId") Long districtId, @Param("date") String date);


    // 历史积存量趋查询（近一周）
//    080f2de9-194e-4672-9536-84c48f3b6e5e
    List<Report> storageHistoryAxisListByLatestWeek(@Param("flag") String flag, @Param("districtId") Long districtId);
    List<Report> storageHistoryAxisListByLatestWeek(@Param("countyId") Long countyId, @Param("flag") String flag,
                                                    @Param("districtId") Long districtId);

    // 历史积存量趋查询（按月查询：yyyy-MM ）
//    56700de9-67a5-4b5e-b6f0-56f56fcdc547
    List<Report> storageHistoryAxisListByYearMonth(@Param("countyId") Long countyId, @Param("flag") String flag,
                                                   @Param("districtId") Long districtId,
                                                   @Param("startDay") String startDay, @Param("endDay")String endDay);

    // 历史积存量趋查询（按年查询：yyyy）
//    8a72ab6c-b1fd-4eee-ba32-35f8286d6ae8
    List<Report> storageHistoryAxisListByYear(@Param("countyId") Long countyId, @Param("flag") String flag,
                                              @Param("districtId") Long districtId,
                                              @Param("startDay") String startDay, @Param("endDay")String endDay);

    // 省市区县医废向下钻取 -- 按医疗机构统计医废
    List<Report> getStatisticalWithHospital(@Param("deptId")Long deptId, @Param("startDate")String startDate,
                                            @Param("endDate")String endDate);

    // 省市区县医废向下钻取 -- 医疗机构下辖机构
    List<Report> getHospitalManagerHospital(@Param("deptId")Long deptId, @Param("startDate")String startDate,
                                            @Param("endDate")String endDate);




    Report previewComponyMain(@Param("ids") List<Long> ids);
}
